import axios from 'axios';
//接口前缀
const baseUrl='https://tax.lxboma.com/b';
/**
 * 封装get方法
 * @param url
 * @param data
 * @returns {Promise}
 */
export const prefixUrl='https://tax.lxboma.com';
export function get(url,params={}){
    return new Promise((resolve,reject) => {
        axios.get(baseUrl+url,{
          params:params
        })
        .then(response => {
          resolve(response.data);
        })
        .catch(err => {
          reject(err);
        })
    })
}
/**
 * 封装post请求
 * @param url
 * @param data
 * @returns {Promise}
 */

export function post(url,data = {},config){
    return new Promise((resolve,reject) => {
        axios.post(baseUrl+url,data,config).then(response => {
//      	console.log(response)
        	if(response.status==200){
        		resolve(response.data);
        	}else if(response.status==444){
        		resolve(response.status);
        	}
        },err => {
          reject(err);
//        console.log(err)
        })
    })
}

/**
 * 封装patch请求
 * @param url
 * @param data
 * @returns {Promise}
 */

export function patch(url,data = {}){
    return new Promise((resolve,reject) => {
        axios.patch(baseUrl+url,data).then(response => {
          resolve(response.data);
        },err => {
          reject(err)
        })
    })
}

/**
 * 封装put请求
 * @param url
 * @param data
 * @returns {Promise}
 */

export function put(url,data = {}){
    return new Promise((resolve,reject) => {
        axios.put(baseUrl+url,data).then(response => {
          resolve(response.data);
        },err => {
        	reject(err)
        })
    })
}
